// 新增独立的路由监听Hook
import { watch } from 'vue'
import { useRoute } from 'vue-router'

export function watchRouteQuery(fetchFn: (params: Record<string, any>) => void) {
  const route = useRoute()

  watch(
    () => route.query,
    () => {
      fetchFn(route.query)
    },
    { deep: true, immediate: true }
  )
}
